/**
 * 
 */
package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgBc;
import edu.wpi.cs509.representation.GameID;

/**
 * This class implements the message from the client to 
 * the server indicating that the player is done with setup
 * and the game playing can begin.
 * @author sparadis
 *
 */
public class MsgPlayerReady extends MsgServerContext {

	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * gId: id of game to join
	 */
	protected GameID gId;
	
	/**
	 * Constructor
	 * @param gId - id of game to join.
	 */
	public MsgPlayerReady(GameID gId) {
		this.gId = gId;
	}

	/**
	 * Call the server's player-ready function.
	 * @return null - this tells the message auto-reply code not to send
	 *                a reply message. The server code will send the 
	 *                replies.
	 */
	@Override
	public MsgBc doExecuteAndGetReply() {
		//Call the server's player-ready function. The server will 
		//send the reply messages to the requester and opponent,
		//so we return NULL here so the auto-reply code doesn't send a 
		//reply message.
		getServer().playerReady(gId, getConnection());
		return null;
	}

}
